package com.shiguiwu.springmybatis.spring.lifecycle.parse;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;

/**
 * @description: 属性文件解析
 * @author: stone
 * @date: Created by 2021/3/22 10:41
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.lifecycle.parse
 */
public class PropParseTests {

    public static void main(String[] args) {
        //1 定义一个容易
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        //2 创建读取器
        PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(beanFactory);

        //3 加载文件
        reader.loadBeanDefinitions("spring/prop.properties");

        //4 取出容器中的 bean
        String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanFactory.getBean(beanDefinitionName));
            System.out.println(beanFactory.getBeanDefinition(beanDefinitionName).getClass().getName());
            System.out.println("========================================");
        }
    }
}
